package com.huiztech.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class FormatTime {
    public static String getDateTimes() {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String result = sdf.format(calendar.getTime());
        return result;
    }
    //yyyy-MM-dd
    //HH:mm:ss
    public static String getDateTimes(String type) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(type);
        String result = sdf.format(calendar.getTime());
        return result;
    }

    public static String getDay() {
        String day="";
        Date date=new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        switch (cal.get(Calendar.DAY_OF_WEEK)) {
        case 1:
            day="星期日";
            break;
        case 2:
            day="星期一";
            break;
        case 3:
            day="星期二";
            break;
        case 4:
            day="星期三";
            break;
        case 5:
            day="星期四";
            break;
        case 6:
            day="星期五";
            break;
        case 7:
            day="星期六";
            break;
        default:
            break;
        }
        return day;
    }

    public static String formatTimeFromMMToTime(String timeMM) {
        long date = Long.valueOf(timeMM) * 1000;
        Date data = new Date(date);
        String str = new SimpleDateFormat("yyyy-MM-dd").format(data);
        return str;
    }

    public static String formatTimeFromMMToTime(long timeMM) {
        //long date = Long.valueOf(timeMM);
        Date data = new Date(timeMM);
        String str = new SimpleDateFormat("yyyy-MM-dd").format(data);
        return str;
    }

    public static long getMillis(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.getTimeInMillis();
    }
}
